const {topMovie,hotMovie,comingMovie} = require("../../models/home")
const {star} = require("../../utils/index")
Page({
  data: {
    movies:""
  },
  onLoad:async function() {
    var http = [topMovie,hotMovie,comingMovie]
    var title={
      topMovie:"top250",
      hotMovie:"正在热映",
      comingMovie:"即将上映"
    }
    var movies ={}
    for(let item of http){
      var res = await item()
      var arr = res.data.result
      arr.forEach(item=>{
        item.star = star(item.raiting)
      })
      movies[item.name]={
        title:title[item.name],
        data:arr.slice(0,3)
      }
    }
    this.setData({
      movies
    })
  }
})
